/*
 * @lc app=leetcode.cn id=17 lang=javascript
 *
 * [17] 电话号码的字母组合
 */

// @lc code=start
/**
 * @param {string} digits
 * @return {string[]}
 */
var letterCombinations = function (digits) {
    if(digits==="")return []
  let map = new Map([
    [2, "abc"],
    [3, "def"],
    [4, "ghi"],
    [5, "jkl"],
    [6, "mno"],
    [7, "pqrs"],
    [8, "tuv"],
    [9, "wxyz"],
  ]);
  let res = [];
  let dfs = function (i, str) {
    if (str.length === digits.length) {
      res.push(str);
      return;
    }
    let temp0 = map.get(Number(digits[i]));
    for (let item of temp0) {
      let temp = str + item;
      dfs(i + 1, temp);
    }
  };
  dfs(0, "");
  return res;
};
// @lc code=end

letterCombinations("23");
